package com.example.dormitory_manager.controller;


import com.example.dormitory_manager.form.SearchForm;
import com.example.dormitory_manager.service.MoveoutService;
import com.example.dormitory_manager.service.StudentService;
import com.example.dormitory_manager.utils.ResultVOUtil;
import com.example.dormitory_manager.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author admin
 * @since 2022-10-02
 */
@RestController
@RequestMapping("/moveout")
public class MoveoutController {
    @Autowired
    private MoveoutService moveoutService;

    @GetMapping("/list/{page}/{size}")
    public ResultVo list(@PathVariable("page") Integer page, @PathVariable("size") Integer size) {
        return ResultVOUtil.success(this.moveoutService.list(page, size));
    }

    @GetMapping("/search")
    public ResultVo search(@RequestBody SearchForm searchForm){
        return  ResultVOUtil.success(this.moveoutService.search(searchForm));
    }

    @PutMapping("/moveout/{id}/{reason}")
    public ResultVo moveout(@PathVariable("id") Integer id,@PathVariable("reason") String reason){
        return  this.moveoutService.moveout(id,reason);
    }

    @GetMapping("/moveoutList/{page}/{size}")
    public ResultVo moveoutList(@PathVariable("page") Integer page, @PathVariable("size") Integer size) {
        return ResultVOUtil.success(this.moveoutService.moveoutList(page, size));
    }


}

